import datetime

from rest_framework import serializers

from blog import models


class CodeTagDateSerializer(serializers.ModelSerializer):
    class Meta:
        model = models.CodeTagDate
        # ('__all__')[不是('_all__',)]  与 ('f1','f2',)
        fields = ('__all__')
        depth = 1
    # id = serializers.IntegerField(read_only=True)
    # code = serializers.CharField(max_length=255)
    # name = serializers.CharField(max_length=255, required=False)
    # tag = serializers.CharField(max_length=255)
    # date = serializers.DateField()
    # source = serializers.CharField(max_length=255, required=False)
    # enable = serializers.IntegerField(default=1, required=False)
    # storage_date = serializers.DateField(default=datetime.date.today())
    #
    # def create(self, validated_data):
    #     """
    #     创建并返回一个Snippets实例化对象，并且给出验证数据
    #     """
    #     return CodeTagDate.objects.create(**validated_data)
    #
    # def update(self, instance, validated_data):
    #     """
    #     更新并且返回一个已存在的Snippets实例化对象，并给出验证数据
    #     """
    #     instance.title = validated_data.get('title', instance.title)
    #     instance.code = validated_data.get('code', instance.code)
    #     instance.linenos = validated_data.get('linenos', instance.linenos)
    #     instance.language = validated_data.get('language', instance.language)
    #     instance.style = validated_data.get('style', instance.style)
    #     instance.save()
    #     return instance
